package com.jj.test;

import com.jj.ApplicationConfig;
import com.jj.User;
import com.jj.dao.UserDao;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public  class test{
public static void main(String[] args) {
    ApplicationContext context = new AnnotationConfigApplicationContext(ApplicationConfig.class);
    User user = context.getBean(User.class);
    System.out.println("User：" + user);
    // 测试Druid数据源
    DataSource ds = context.getBean(DataSource.class);
    try (Connection conn = ds.getConnection()) {
        System.out.println("数据库连接状态：" + (!conn.isClosed()));
    } catch (SQLException e) {
        throw new RuntimeException(e);
    }
}

}